﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema
    targetNamespace="http://LateBindingApi.Office.com/XMLSchema.xsd" elementFormDefault="qualified" 
    xmlns="http://LateBindingApi.Office.com/XMLSchema.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"
>

  <xs:element name="LateBindingApi.CodeGenerator.Document">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Components" type="Components" />
        <xs:element name="Externals" type="Externals" />
        <xs:element name="Solution" type="Solution" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  
  <xs:complexType name="RefComponents">
    <xs:sequence>
      <xs:element name="RefComponent" type="RefComponent" minOccurs ="0" maxOccurs ="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="RefComponent">
    <xs:attribute name="Key" type="xs:string" use="required" />   <!-- component key or external key -->
  </xs:complexType>

  <xs:complexType name="GUIDs">
    <xs:sequence>
      <xs:element name="GUID" type="GUID" minOccurs ="0" maxOccurs ="unbounded"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="GUID">
    <xs:attribute name="Guid"          type="xs:string" use="required" /> <!-- guid value -->
    <xs:attribute name="ComponentKey"  type="xs:string" use="required" /> <!-- component key -->
  </xs:complexType>
  
  <xs:complexType name="RefInterfaces">
    <xs:sequence>
      <xs:element name="RefInterface" type="RefInterface" minOccurs ="0" maxOccurs ="unbounded"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="RefInterface">
    <xs:attribute name="Key" type="xs:string" use="required" />  <!-- interface key -->
  </xs:complexType>

  <xs:complexType name="Components">
    <xs:sequence>
      <xs:element name="Component" type="Component" minOccurs ="0" maxOccurs ="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="Component">
    <xs:sequence>
    </xs:sequence>
    <xs:attribute name="Name"           type="xs:string" />       <!-- Component Name -->
    <xs:attribute name="ContainingFile" type="xs:string"/>        <!-- Assembly Path -->
    <xs:attribute name="Key"            type="xs:string" />       <!-- Generated unique Key for the Component -->
    <xs:attribute name="GUID"           type="xs:string" />       <!-- Component GUID -->
    <xs:attribute name="HelpFile"       type="xs:string"/>        <!-- Helpfile Path -->
    <xs:attribute name="MajorVersion"   type="xs:unsignedByte" /> <!-- TypeLib MajorVersion -->
    <xs:attribute name="MinorVersion"   type="xs:unsignedByte" /> <!-- TypeLib MinorVersion -->
    <xs:attribute name="LCID"           type="xs:unsignedByte" /> <!-- TypeLib LCID -->
    <xs:attribute name="Description"    type="xs:string" />       <!-- Description of TypeLib -->
    <xs:attribute name="Version"        type="xs:string" />       <!-- SupportByLibrary Value -->
    <xs:attribute name="SysKind"        type="xs:unsignedByte" /> <!-- WIN16 WIN32 or Mac -->
  </xs:complexType>
  
  <xs:complexType name="Externals">
    <xs:sequence>
      <xs:element name="External"   type="External"  minOccurs ="0" maxOccurs ="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="External">
    <xs:sequence>
      <xs:element name="ExternalComponents" type="ExternalComponents"/>
    </xs:sequence>
    <xs:attribute name="Name"       type="xs:string" use="required" /> <!-- Name of the external -->
    <xs:attribute name="Prefix"     type="xs:string" use="required" /> <!-- Class Prefix -->    
    <xs:attribute name="Namespace"  type="xs:string" use="required" /> <!-- Namespace -->
    <xs:attribute name="Key"        type="xs:string" use="required" /> <!-- Generated unique Key for the External -->
  </xs:complexType>
  
  <xs:complexType name="ExternalComponents">
    <xs:sequence>
      <xs:element name="ExternalComponent"   type="ExternalComponent"  minOccurs ="0" maxOccurs ="unbounded"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="ExternalComponent">
    <xs:sequence>     
    </xs:sequence>
    <xs:attribute name="Key"          type="xs:string" />       <!-- Generated unique Key for the ExternalComponent -->
    <xs:attribute name="GUID"         type="xs:string" />       <!-- Component GUID-->
    <xs:attribute name="MajorVersion" type="xs:unsignedByte" /> <!-- TypeLib MajorVersion -->
    <xs:attribute name="MinorVersion" type="xs:unsignedByte" /> <!-- TypeLib MinorVersion -->
    <xs:attribute name="Description"  type="xs:string" />       <!-- Description of TypeLib -->
    <xs:attribute name="SysKind"      type="xs:unsignedByte" /> <!-- WIN16 WIN32 or Mac -->
  </xs:complexType>
  
  <xs:complexType name="Solution">
    <xs:sequence>
      <xs:element name="Projects" type="Projects" />
    </xs:sequence>
    <xs:attribute name="Name" type="xs:string" use="required" /> <!-- name of solution.sln -->
  </xs:complexType>
  
  <xs:complexType name="Projects">
    <xs:sequence>
      <xs:element name="Project" type="Project" minOccurs ="0" maxOccurs ="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="Project">
    <xs:sequence>
      <xs:element name="Enums"              type="Enums"/>
      <xs:element name="CoClasses"          type="CoClasses"/>
      <xs:element name="DispatchInterfaces" type="DispatchInterfaces"/>
      <xs:element name="Interfaces"         type="Interfaces"/>
      <xs:element name="RefComponents"      type="RefComponents" />
    </xs:sequence>
    <xs:attribute name="Name"        type="xs:string" use="required" /> <!-- name of project -->
    <xs:attribute name="ProjectName" type="xs:string" use="required" /> <!-- name of project.csharp -->
    <xs:attribute name="Namespace"   type="xs:string" use="required" /> <!-- namespace of project -->
    <xs:attribute name="Prefix"      type="xs:string" use="required" /> <!-- class prefix of project -->
    <xs:attribute name="Key"         type="xs:string" use="required" /> <!-- unique key of project -->
  </xs:complexType>

  <xs:complexType name="Interfaces">
    <xs:sequence>
      <xs:element name="Interface" type="Interface" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="Interface">
    <xs:sequence>
      <xs:element name="Methods"              type="Methods" />
      <xs:element name="Properties"           type="Properties" />
      <xs:element name="RefComponents"        type="RefComponents" />
      <xs:element name="GUIDs"                type="GUIDs" />
      <xs:element name="InheritedInterfaces"  type="RefInterfaces" />
    </xs:sequence>
    <xs:attribute name="Name"                 type="xs:string"  use="required" /> <!-- interface name: readonly -->
    <xs:attribute name="Caption"              type="xs:string"  use="required" /> <!-- interface caption -->
    <xs:attribute name="Key"                  type="xs:string"  use="required" /> <!-- unique key -->
  </xs:complexType>

  <xs:complexType name="DispatchInterfaces">
    <xs:sequence>
      <xs:element name="DispatchInterface" type="DispatchInterface" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="DispatchInterface">
    <xs:sequence>
      <xs:element name="Methods"              type="Methods" />
      <xs:element name="Properties"           type="Properties" />
      <xs:element name="RefComponents"        type="RefComponents" />
      <xs:element name="GUIDs"                type="GUIDs" />
      <xs:element name="InheritedInterfaces"  type="RefInterfaces" />
    </xs:sequence>
    <xs:attribute name="Name"                 type="xs:string"  use="required" /> <!-- interface name: readonly -->
    <xs:attribute name="Caption"              type="xs:string"  use="required" /> <!-- interface caption -->
    <xs:attribute name="Key"                  type="xs:string"  use="required" /> <!-- unique key -->
  </xs:complexType>

  <xs:complexType name="CoClasses">
    <xs:sequence>
      <xs:element name="CoClass" type="CoClass" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="CoClass">
    <xs:sequence>
      <xs:element name="Methods"              type="Methods" />
      <xs:element name="Properties"           type="Properties" />
      <xs:element name="RefComponents"        type="RefComponents" />
      <xs:element name="GUIDs"                type="GUIDs" />
      <xs:element name="EventInterface"       type="RefInterface" />
      <xs:element name="InheritedInterfaces"  type="RefInterfaces" />
    </xs:sequence>
    <xs:attribute name="Name"                 type="xs:string"  use="required" /> <!-- interface name: readonly -->
    <xs:attribute name="Caption"              type="xs:string"  use="required" /> <!-- interface caption -->
    <xs:attribute name="Key"                  type="xs:string"  use="required" /> <!-- unique key -->
  </xs:complexType>
  
  <xs:complexType name="DispIds">
    <xs:sequence>
      <xs:element name="DispId" type="DispId" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="DispId">
    <xs:attribute name="Id"           type="xs:integer" use="required" />  <!-- dispatch -->
    <xs:attribute name="ComponentKey" type="xs:integer" use="required" />  <!-- component key or external key -->
  </xs:complexType>

  <xs:complexType name="Enums">
    <xs:sequence>
      <xs:element name="Enum" type="Enum" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="Enum">
    <xs:sequence>
      <xs:element name="EnumMembers"   type="EnumMembers" />
      <xs:element name="RefComponents" type="RefComponents" />
    </xs:sequence>
    <xs:attribute name="Name"          type="xs:string"  /> <!-- enum name -->
  </xs:complexType>

  <xs:complexType name="EnumMembers">
    <xs:sequence>
      <xs:element name="EnumMember" type="EnumMember" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="EnumMember">
    <xs:sequence>
      <xs:element name="RefComponents" type="RefComponents" />
    </xs:sequence>
    <xs:attribute name="Name"          type="xs:string"  />   <!-- member name -->
    <xs:attribute name="Value"         type="xs:integer" />   <!-- member value -->
  </xs:complexType>
 
  <xs:complexType name="Property">
    <xs:sequence>
      <xs:element name="DispIds"              type="DispIds" />
      <xs:element name="RefComponents"        type="RefComponents" />
      <xs:element name="Parameters"           type="Parameters" minOccurs="0" maxOccurs="unbounded" /> 
    </xs:sequence>
    <xs:attribute name="Name"                 type="xs:string"  /> <!-- property name :Readonly -->
    <xs:attribute name="Caption"              type="xs:string"  /> <!-- property caption -->
    <xs:attribute name="Key"                  type="xs:string"  /> <!-- unique key -->
    <xs:attribute name="InvokeKind"           type="xs:string"  /> <!-- GET PUT or PUTREF -->
    <xs:attribute name="SourceKey"            type="xs:string"  /> <!-- project key or external key there is the property type defined -->
  </xs:complexType>
  
  <xs:complexType name="Properties">
    <xs:sequence>
      <xs:element name="Property" type="Property" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="Method">
    <xs:sequence>
      <xs:element name="DispIds"              type="DispIds" />
      <xs:element name="RefComponents"        type="RefComponents" />
      <xs:element name="Parameters"           type="Parameters" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
    <xs:attribute name="Name"                 type="xs:string"  /> <!-- method name :Readonly -->
    <xs:attribute name="Caption"              type="xs:string"  /> <!-- method caption -->
    <xs:attribute name="Key"                  type="xs:string"  /> <!-- unique key -->
    <xs:attribute name="HasReturnType"        type="xs:boolean" /> <!-- method have a return value -->
  </xs:complexType>

  <xs:complexType name="ReturnValue">
    <xs:sequence>
    </xs:sequence>
    <xs:attribute name="IsComProxy"     type="xs:boolean" /> <!-- return value is a com object -->
    <xs:attribute name="IsExternal"     type="xs:boolean" /> <!-- return value type is defined in external library-->
    <xs:attribute name="IsArray"        type="xs:boolean" /> <!-- return value is an array -->
    <xs:attribute name="Type"           type="xs:string"  /> <!-- return value type -->
    <xs:attribute name="TypeKind"       type="xs:string"  /> <!-- return value typekind -->
    <xs:attribute name="SourceKey"      type="xs:string"  /> <!-- project key or external key there is the return type defined -->
  </xs:complexType>

  <xs:complexType name="Methods">
    <xs:sequence>
      <xs:element name="Method" type="Method" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="Parameter">
    <xs:sequence>
    </xs:sequence>
    <xs:attribute name="Name"       type="xs:string"  /> <!-- param name -->
    <xs:attribute name="Caption"    type="xs:string"  /> <!-- param caption -->
    <xs:attribute name="IsExternal" type="xs:boolean" /> <!-- param type is defined in external library -->
    <xs:attribute name="IsComProxy" type="xs:boolean" /> <!-- param is a com object  -->
    <xs:attribute name="IsOptional" type="xs:boolean" /> <!-- param is an optional -->
    <xs:attribute name="IsRef"      type="xs:boolean" /> <!-- param is given byRef -->
    <xs:attribute name="IsArray"    type="xs:boolean" /> <!-- param is an array -->
    <xs:attribute name="Type"       type="xs:string"  /> <!-- param type -->
    <xs:attribute name="TypeKind"   type="xs:string"  /> <!-- param typekind -->
    <xs:attribute name="SourceKey"	type="xs:string"  /> <!-- project key or external key there is the param type defined -->
  </xs:complexType>

  <xs:complexType name="Parameters">
    <xs:sequence>
      <xs:element name="Parameter" type="Parameter" minOccurs="0" maxOccurs="unbounded" />
      <xs:element name="ReturnValue" type="ReturnValue" />
      <xs:element name="RefComponents" type="RefComponents" />
    </xs:sequence>
  </xs:complexType>

</xs:schema>